package Day10;

import Day09.BadException;
import Day09.UsernameNotFoundException;

import java.util.Scanner;

public class Login {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws BadException, UsernameNotFoundException {
        System.out.println("请输入用户名");
        String name = sc.next();
        System.out.println("请输入密码");
        String  cipher = sc.next();
        login(name,cipher);

    }

    public static void login(String name,String cipher)throws UsernameNotFoundException,BadException {
        try {
            if("admin".equals(name)){
                if("123456".equals(cipher)){
                    System.out.println("登录成功啦");
                }else{
                    throw new BadExceeption("密码输入错误");
                }
            }else{
                throw new UsernameException("用户名输入错误啦");
            }
        } catch (UsernameException e) {
            e.printStackTrace();
        } catch (BadExceeption e) {
            e.printStackTrace();
        }

    }


}
